#include <stdio.h>
int main()
{
	char result[200] = {0};
	int x = 0, m = 0;
	scanf("%d %d", &x, &m);
	int idx = 0;
	while( x != 0 )
	{
		int temp = x % m;
		x = x / m;
		if ( temp >= 10 )
		{
			result[idx] = 'A' + (temp - 10);
		}
		else
		{
			result[idx] = '0' + temp;
		}
		idx ++;
	}
	idx --;
	for (; idx>=0; idx-- )
	{
		printf("%c", result[idx]);
	}
	return 0;
}
